package com.lagouedu.config;

import com.lagouedu.filter.MethodTakeTime;

import java.util.TreeSet;
import java.util.stream.Collectors;

public class MonitorTask implements Runnable{
    @Override
    public void run() {
        //
        while(true){
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            TreeSet<Long> longsA = new TreeSet<>(MethodTakeTime.METHODA_TIME_QUE);
            TreeSet<Long> longsB = new TreeSet<>(MethodTakeTime.METHODB_TIME_QUE);
            TreeSet<Long> longsC = new TreeSet<>(MethodTakeTime.METHODC_TIME_QUE);
            System.out.println("methodA top90" + longsA.stream().limit(90).collect(Collectors.toSet()).toString());
            System.out.println("methodA top99" + longsA.stream().limit(99).collect(Collectors.toSet()).toString());
            System.out.println("methodB top90" + longsB.stream().limit(90).collect(Collectors.toSet()).toString());
            System.out.println("methodB top99" + longsB.stream().limit(99).collect(Collectors.toSet()).toString());
            System.out.println("methodC top90" + longsC.stream().limit(90).collect(Collectors.toSet()).toString());
            System.out.println("methodC top99" + longsC.stream().limit(99).collect(Collectors.toSet()).toString());
        }

    }
}
